const state = {
  isCollapse: false,
  selectMenu: [],
}
const mutations = {
  collapseMenu(state) {
    console.log('111')
    state.isCollapse = !state.isCollapse
  },
  addMenu(state, payload) {
    // 对数据进行去重处理
    if (state.selectMenu.findIndex(item => item.path === payload.path) === -1) {
      state.selectMenu.push(payload)
    }
  },
  closeMenu(state, payload) {
    // 找到点击关闭的菜单的索引
    const index = state.selectMenu.findIndex(item => item.name === payload.name)
    // 删除指定索引的菜单
    state.selectMenu.splice(index, 1)
  },
}

export default {
  state,
  mutations,
}
